const { contextBridge } = require("electron");
const { ipcRenderer } = require("electron/renderer");

// 获取token
const getTokenAndPort = () => {
  let data = ipcRenderer.invoke("getTokenAndPort-ipc");
  return data;
};

// 获取参数
const getConfig = async (key) => {
  return await ipcRenderer.invoke("getConfig-ipc", key);
};

// 写入参数
const setConfig = async (key, value) => {
  return await ipcRenderer.invoke("setConfig-ipc", key, value);
};
// 写入日志
const setLog = async (value) => {
  return await ipcRenderer.invoke("setLog-ipc",value);
};

contextBridge.exposeInMainWorld("config", {
  getTokenAndPort,
  getConfig,
  setConfig,
  setLog
});
